import 'dart:io';

import 'package:file_transfer/pojo/message.dart';
import 'package:file_transfer/store/file_store.dart';
import 'package:flutter/widgets.dart';

class SimpleModel with ChangeNotifier{

  // 是否为主页
  bool _mainPage = true;
  bool get mainPage => _mainPage;
  set mainPage(bool value){
    _mainPage = value;
    notifyListeners();
  }
  // 设置页面为主页
  setPageToMain(){
    _mainPage = true;
    notifyListeners();
  }
  // 设置页面为文件传输页面
  setPageToFileTransfer(){
    _mainPage = false;
    notifyListeners();
  }


  // ws连接状态
  bool _wsConnectState = false;
  bool get wsConnectState => _wsConnectState;
  set wsConnectState(bool value){
    _wsConnectState = value;
    notifyListeners();
  }

  // 登录状态
  bool _isLogin = false;
  bool get isLogin => _isLogin;
  set isLogin(bool value){
    _isLogin = value;
    notifyListeners();
  }


  // 分享的文件类型 文件/文本
  bool isShareFile = false;

  // 分享的文件
  List<File> _shareFileList = [];
  List<File> get shareFileList => _shareFileList;
  set shareFileList(List<File> value){
    _shareFileList = value;
    notifyListeners();
  }
  addShareFile(File file){
    _shareFileList.add(file);
  }

  // 分享的文本
  String shareText = "1212";

  // 接收的文件保存目录
  String _receiveDirectoryPath = "";
  String get receiveDirectoryPath => _receiveDirectoryPath;
  set receiveDirectoryPath(String value){
    _receiveDirectoryPath = value;
    // 持久化存储
    saveFileConfig(value);
    notifyListeners();
  }


  // 登录的用户信息
  User _userInfo = User(name: "未登录");
  User get userInfo => _userInfo;
  set userInfo(User value){
    _userInfo = value;
    notifyListeners();
  }
  void clearUserInfo(){
    _userInfo = User(name: "未登录");
    notifyListeners();
  }



}

